package com.ee.chat.admin.controller.home;

import com.ee.chat.admin.service.IHomeService;
import com.ee.chat.common.bean.Result;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

/**
 * @Author AppiJ
 * @Date 2020/5/13 16:05
 */
@RestController
@RequestMapping("home")
public class HomeController {
    private Logger log = LoggerFactory.getLogger(HomeController.class);

    @Resource
    IHomeService homeService;

    /**
     * 用户注册量统计数据
     * @Author AppiJ
     * @Date 2020/5/13 16:06
     * @param type  1-月  2-年
     * @return
     */
    @RequestMapping("registerStatics")
    public Result registerStatics(HttpServletRequest request, @RequestParam Integer type){
        try{
            return homeService.registerStatics(request, type);
        }catch (Exception e){
            log.error("【用户注册量统计数据错误】", e);
        }
        return Result.returnFailure();
    }

    /**
     * 用户充值提现统计数据
     * @Author AppiJ
     * @Date 2020/5/14 12:10
     * @param type  1-月  2-年
     * @return
     */
    @RequestMapping("rechargeWithdrawStatics")
    public Result rechargeWithdrawStatics(HttpServletRequest request, @RequestParam Integer type){
        try{
            return homeService.rechargeWithdrawStatics(request, type);
        }catch (Exception e){
            log.error("【用户充值提现统计数据错误】", e);
        }
        return Result.returnFailure();
    }
}
